-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: rpc send transfer recipient choose fee #5238
Conversation
0c65366
to
a9ac595
Compare
Thanks @alter-eggo, think we should include in this PR:
|
04e11d2
to
e387351
Compare
(value, context) => { | ||
const contextOptions = context.options as any; | ||
const network = contextOptions.from[1].value.network as BitcoinNetworkModes; | ||
return btcAddressNetworkValidator(network).isValidSync(value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
magic number, what's 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems, there is no other ways to get network here
{} as Record<AddressType, number> | ||
); | ||
|
||
const outputsData = (Object.keys(outputTypesLengthMap) as AddressType[]).map(v => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is v? please name fully
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed to outputAddressType
(acc: Record<AddressType, number>, outputType) => { | ||
// we add 1 output for change address if not sending max | ||
if (!acc['p2wpkh'] && !isSendMax) { | ||
acc['p2wpkh'] = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default output length value
// Fee has already been deducted from the amount with send all | ||
const outputs = recipients.map(({ address, amount }) => ({ value: BigInt(amount), address })); | ||
|
||
const fee = Math.ceil(sizeInfo.txVBytes * feeRate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use BigNumber for math
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
most of this fn is copy-pasted, I can refactor math there later?
e387351
to
84f2919
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @alter-eggo. Let's follow up with tests and refactor as soon as this is shipped!
84f2919
to
a739014
Compare
This pr fixes bug with rpc send transfer fees selection. Here I just duplicated components in order not to affect other flows. In next pr I will refactor it